#include <stdio.h>
#include <string.h>
void get_extension(const char *file_name, char *extension);
int main(void)
{
    char extension[10];
    get_extension("test1.txt", extension);
    printf("%ld \"%s\"\n", strlen(extension), extension);
    get_extension("test2", extension);
    printf("%ld \"%s\"\n", strlen(extension), extension);
    get_extension("test3.txt.bak", extension);
    printf("%ld \"%s\"\n", strlen(extension), extension);
    return 0;
}
void get_extension(const char *file_name, char *extension) {
    const char *p;
    for (p = file_name + strlen(file_name); p - file_name; p--)
        if (*p == '.') {
            strcpy(extension, &file_name[p - file_name + 1]);
            return;
        }
    *extension = '\0';
}